<template>
  <svg :class="[svgClass,]" aria-hidden="true" v-on="$listeners">
    <use :xlink:href="iconName"/>
  </svg>
</template>

<script>
import {mapState, mapGetters} from "vuex";
//isCollapse?'icon-elastic':undefined
export default {
  name: 'SvgIcon',
  props: {
    iconClass: {
      type: String,
      required: true
    },
    className: {
      type: String,
      default: ''
    }
  },
  computed: {
    //映射
    ...mapGetters(['headerIcon']),
    ...mapState(['isCollapse']),
    iconName() {
      return `#icon-${this.iconClass}`
    },
    svgClass() {
      if (this.className) {
        return 'svg-icon ' + this.className
      } else {
        return 'svg-icon'
      }
    },

  }
}
</script>

<style scoped lang="less">
.svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  color: #7f7f7f;
  cursor: pointer;
  transition:0.5s;
}

//头组件图标
.icon-header-left {
  margin: 0 20px 0 20px;

  &:hover {
    scale: 1.2;
    color: #000;
  }
}

//菜单组件图标
.icon-aside-menu {
  margin-right: 10px;

  &:hover {
    scale: var(--scale-num);
    color: var(--background-color);
  }
}


</style>